package com.duomai.myapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.duomai.myapplication.R;
import com.duomai.myapplication.adapter.NoticeAdapter;
import com.example.admin.SQLite.TongZhi;
import com.example.admin.SQLite.dao.TongZhiDao;
import com.example.admin.activity.NoticeDetailActivity;
import com.example.admin.base.BaseActivity;

import java.util.ArrayList;

public class NoticeActivity extends BaseActivity {
    NoticeAdapter mAdapter;
    TongZhiDao tongZhiDao;
    RecyclerView recyclerView;

    @Override
    public void setContentView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_notice);
        recyclerView = findViewById(R.id.recyclerView);
        mAdapter = new NoticeAdapter();
        recyclerView.setAdapter(mAdapter);
        tongZhiDao = new TongZhiDao(this);
        getdata();
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                startActivity(new Intent(NoticeActivity.this, NoticeDetailActivity.class)
                        .putExtra("bean", mAdapter.getItem(position)));
            }
        });
    }

    @Override
    public void setInitView() {

    }

    private void getdata() {
        ArrayList<TongZhi> list = tongZhiDao.FindWhereData();
        mAdapter.setNewData(list);
    }
}